var Consts = require('../../../util/consts');

module.exports = function (app) {
    return new RoomRemote(app);
};


var RoomRemote = function (app) {
    this.app = app;
    this.roomService = this.app.get('roomService');
};

/**
 *
 * 如何处理取决于回调函数 cb
 * @param msg {username:xxx}
 * @param session
 * @param next
 */
RoomRemote.prototype.whoami = function (username, rid, cb) {
    this.roomService.get(rid, cb);
};

RoomRemote.prototype.getMembers = function (rid, cb) {
    this.roomService.get(rid, cb);
};

// TODO: Argar platform migration -- using new chat room!
RoomRemote.prototype.createRoom = function (master, rid, usernames, cb) {

    this.roomService.add(rid, {master: master, users: JSON.parse(usernames)}, cb);
};

RoomRemote.prototype.getRoom = function(rid, cb) {
    this.roomService.get(rid, cb);
};